package com.kaifamiao.demo.d0824;

import java.time.Instant;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.time.temporal.WeekFields;
import java.util.Date;
import java.util.Locale;

public class Demo {


    public static void main(String[] args) {
//        System.out.println(System.currentTimeMillis());
//        System.out.println(System.nanoTime());
        /*
         日期/时间:
            java.util.Date 表示特定的时间瞬间
         */
        Date date = new Date();

        System.out.println(date);
        System.out.println( date.getYear() );
        System.out.println( date.getMonth() );
        System.out.println( date.getDay() ); // day of week
        System.out.println( date.getDate() ); // day of month
        System.out.println( date.getHours() );
        System.out.println( date.getMinutes() );
        System.out.println( date.getSeconds() );

        Date date1 = new Date(122, 7, 32);
        System.out.println(date1);


        Date date2 = new Date(1000L * 60 * 60 * 24 * 365 * 52 + 1000L * 60 * 60 * 24 * 30 * 8);

        System.out.println(date2);


        System.out.println(date.after(date2));
        System.out.println(date.before(date2));

        System.out.println(date);
        System.out.println(date.toLocaleString());
        System.out.println(date.toGMTString());

        Instant instant = date.toInstant();

        System.out.println(instant.get(ChronoField.MICRO_OF_SECOND));

        System.out.println(instant.minus(1L, ChronoUnit.DAYS));
        System.out.println(instant.plus(1L, ChronoUnit.DAYS));

        Instant now = Instant.now();

        System.out.println(now);

        System.out.println(Instant.parse("2007-12-03T10:15:30.00Z"));
    }
}
